﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Component1 :TextBox
    {
        public Component1()
        {
            InitializeComponent();
        }
        public override string Text
        {
            get
            {
                return base.Text;
            }
            set
            {
                base.Text = value;
            }
        }
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            if (e.KeyChar == (char)13)
            {
                MessageBox.Show("你按下了回车");
            }
            else
            {
                MessageBox.Show(e.KeyChar.ToString());
            }
        }
        public Component1(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }
    }
}
